package st.business.tepth.business.user.busnumber.finishholder.repair;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.bean.CompleteInfoBean;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-04-11 15:37
 */

public class FinishRepairPresenter extends FinishRepairContract.Presenter {
    private final FinishRepairContract.View mView;
    private final FinishRepairContract.Model mModel;

    public FinishRepairPresenter(FinishRepairContract.View view) {
        mView = view;
        mModel = new FinishRepairModel();
    }

    @Override
    void getInfo(String token, int repairId) {
        addDisposable(mModel.getInfo(token, repairId, new OnDataConvertListener<CompleteInfoBean>() {
            @Override
            public void convert(CompleteInfoBean completeInfoBean) {
                if (completeInfoBean != null) {
                    mView.showInfos(completeInfoBean);
                }
            }

            @Override
            public void error(int code, String msg) {
                mView.showError(msg);
            }
        }));
    }

    @Override
    void rework(String token, int repairId,String repairTaskIds, String reason) {
        addDisposable(mModel.rework(token, repairId,repairTaskIds, reason,
                new OnDataConvertListener<String>() {
                    @Override
                    public void convert(String s) {
                        mView.reworkSucceed();
                    }

                    @Override
                    public void error(int code, String msg) {
                        mView.showError(msg);
                    }
                }));
    }
}
